package chapter04

import scala.util.control.Breaks
import scala.util.control.Breaks._

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/4 6:56 PM
 */
object Test06_Break {
  def main(args: Array[String]): Unit = {
    // 使用scala中的Breaks类的break方法
    Breaks.breakable(
      for (i <- 1 to 3) {
        if (i == 2) {
          Breaks.break()
        }
        println(i)
      }
    )
    breakable(
      for (i <- 1 to 3) {
        if (i == 2) {
          break()
        }
        println(i)
      }
    )
    println("循环外")
  }

}
